package com.example.doudou.demos.config;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author fangtao
 * @projectName doudou
 * @date 2025/6/4
 * @description Redisson分布式锁配置文件
 */


@Configuration
public class RedissonConfig {

    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
        Config config = new Config();

        // 单节点模式 (根据实际配置修改)
        config.useSingleServer()
                .setAddress("redis://10.16.1.100:6379")
                .setPassword("Btch.com@admin")
                .setDatabase(9)
                .setConnectionPoolSize(64)
                .setConnectionMinimumIdleSize(10)
                .setTimeout(3000);

        // 集群模式示例
        // config.useClusterServers()
        //       .addNodeAddress("redis://127.0.0.1:7001", "redis://127.0.0.1:7002");

        return Redisson.create(config);
    }
}
